
package {{packagePath}}.controller;

import {{packagePath}}.service.{{className}}Service;
import {{packagePath}}.dto.{{className}}ReqDTO;
import {{packagePath}}.vo.{{className}}RespVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@Slf4j
@Api(tags = "{{className}}--接口")
@RestController
@RequestMapping("/{{pathName}}")
public class {{className}}Controller {

    @Resource
    private I{{className}}Service service;

    @GetMapping("/{id}")
    @ApiOperation(value = "根据id查询")
    public BaseResponse<{{className}}RespVO> queryById(@PathVariable("id") Long id) {
        {{className}}RespVO respVo = service.queryById(id);
        return BaseResponse.success(respVo);
    }

    @PostMapping("/list")
    @ApiOperation(value = "分页查询")
    public BaseResponse<PageResponse<{{className}}RespVO>> page(@Valid @RequestBody PageRequest<{{className}}ReqDTO> pageRequest) {
        PageResponse<{{className}}RespVO> respVoPage = service.page(pageRequest);
        return BaseResponse.success(respVoPage);
    }

    @PostMapping("/all")
    @ApiOperation(value = "列表查询")
    public BaseResponse<List<{{className}}RespVO>> list(@Valid @RequestBody {{className}}ReqDTO reqDto) {
        List<{{className}}RespVO> respVoList = service.list(reqDto);
        return BaseResponse.success(respVoList);
    }

    @PostMapping("/")
    @ApiOperation(value = "新增")
    public BaseResponse<?> add(@Validated @RequestBody {{className}}ReqDTO reqDto) {
        service.add(reqDto);
        return BaseResponse.success();
    }

    @PostMapping("/batch")
    @ApiOperation(value = "批量新增")
    public BaseResponse<?> batchAdd(@Validated @RequestBody List<{{className}}ReqDTO> reqDtoList) {
        service.batchAdd(reqDtoList);
        return BaseResponse.success();
    }

    @PutMapping("/")
    @ApiOperation(value = "更新对象")
    public BaseResponse<?> update(@Validated @RequestBody {{className}}ReqDTO reqDto) {
        service.update(reqDto);
        return BaseResponse.success();
    }

    @DeleteMapping("/{id}")
    @ApiOperation(value = "删除对象")
    public BaseResponse<?> delete(@PathVariable("id") Long id) {
        service.delete(id);
        return BaseResponse.success();
    }

    @DeleteMapping("/batch")
    @ApiOperation(value = "批量删除对象")
    public BaseResponse<?> batchDelete(@RequestBody List<Long> ids) {
        service.batchDelete(ids);
        return BaseResponse.success();
    }
}